// components/cart/cartItem.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    itemChecked: {
      type: Boolean,
      value: false
    },
    itemId: {
      type: String,
      value: '1'
    },
    itemNum: {
      type: Number,
      value: 1
    },
    itemImgSrc: {
      type: String,
      value: '/cart/item.jpg'
    },
    itemName: {
      type: String,
      value: 'MAGIC DRAGON魔杰龙轻柔倍适学步裤'
    },
    itemDescrition: {
      type: String,
      value: '尺寸：L'
    },
    itemPrice: {
      type: String,
      value: '138.00'
    },

  },

  /**
   * 组件的初始数据
   */
  data: {
    imgPath: "/images",
    changeNum:true
    // num: 1,
  },

  observers: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    tapRadio(e) {
       //console.log("tapRadio", e)
      //切称是否选中
      this.setData({
        itemChecked: !this.data.itemChecked
      })

      //触发事件
      this.triggerEvent("onChecked", {
        id: this.data.itemId,
        checked: this.data.itemChecked
      })
    },
    onNumChange(e) {
      //console.log("onNumChange", this.data.changeNum)
      this.triggerEvent("onNumChange", {
        id: this.data.itemId,
        num: e.detail,
        changeNum:false
      })
    }

  },
  lifetimes: {
    attached() {
      const util = require("../../utils/util")
      this.setData({
        imgPath: util.getImgPath()
      })
    }
  }
})